#!/bin/sh
ldd $1 |awk '/ / {print $3}'|sort|fgrep ".so" > deps.1
echo $1
n=`wc -l < deps.1`
echo $n
if [ $n -gt 0 ];then
    dpkg -L libc6 > /tmp/libc6list
    if [ -d ./deps ];then
        rm -rf deps/*
        echo "clear ./deps"
    else
        mkdir -p ./deps
        echo "create ./deps"
    fi
    echo "copy shared libraries"
    for fn in `cat deps.1`;do
        fgrep $fn /tmp/libc6list > /dev/null
	if [ "$?" -eq "1" ];then
            cp $fn ./deps
	    echo "pick $fn"
	else
            echo "exclude $fn"
	fi
    done
fi
rm deps.1
